<!DOCTYPE html>
<html lang="en">
    <head>
		<meta charset="UTF-8">
		<title>服务编辑页面</title>
		<link rel="stylesheet" href="__ADMIN_PATH__/component/pear/css/pear.css" />
	</head>
	<body>
		<form class="layui-form" action="">
			<div class="mainBox">
				<div class="main-container">


					<table class="layui-table">
						<colgroup>
							<col width="150">
							<col width="150">
						</colgroup>
						<thead>
						<tr>
							<th colspan="2" >订单信息</th>
						</tr>
						</thead>
						<tbody>
						<tr>
							<td>订单号：{$info.order_no}</td>
							<td>下单时间：{$info.add_time|date="Y-m-d H:i:s",###}</td>

						</tr>
						<tr>
							<td>服务时间：{$info.service_time|date="Y-m-d H:i:s",###} - {$info.over_time|date="H:i:s",###}</td>
							<td>服务时长：{$info.buy_number_duration}</td>

						</tr>
						<tr>
							<td>车费详情：出组车  全程：{$info.distance}km</td>
							<td>出行费用：{$info.travel_price}</td>

						</tr>
						<tr>
							<td>服务项目：
								{volist name="order_detail" id="vo"}
                                    {$vo.title} ({$vo.price}*{$vo.buy_number}) &nbsp;&nbsp;
								{/volist}
							</td>
							<td>

								<?php
                                    if(!empty($info['extension_data'])) {
                                        $info_extension_array = json_decode($info['extension_data'],true);
                                    }
								?>

								{if condition="isset($info_extension_array)"}
								    {volist name="info_extension_array" id="vo"}
											{$vo.name} {$vo.tips} &nbsp;&nbsp;&nbsp;
								    {/volist}
								{else}
								   无优惠
								{/if}
							</td>

						</tr>
						<tr>
							<td>支付方式：
								{switch $info.payment_id}
									{case 1}微信{/case}
									{case 2}支付宝{/case}
								    {case 3}余额{/case}
								{/switch}
							</td>
							<td>支付金额：{$info.total_price}</td>

						</tr>
						</tbody>
					</table>

					<table class="layui-table">
						<colgroup>
							<col width="150">
							<col width="150">
						</colgroup>
						<thead>
						<tr>
							<th colspan="2" >用户信息</th>
						</tr>
						</thead>
						<tbody>
						<tr>
							<td>用户ID：{$info.user_id}</td>
							<td>下单人：{$info.name}</td>
						</tr>
						<tr>
							<td>联系方式：{$info.mobile}</td>
							<td>服务地址：{$info.province_name} {$info.city_name}  {$info.county_name} {$info.address} {$info.address_des}</td>
						</tr>

						</tbody>
					</table>


					<table class="layui-table">
						<colgroup>
							<col width="150">
							<col width="150">
						</colgroup>
						<thead>
						<tr>
							<th colspan="2" >技师信息</th>
						</tr>
						</thead>
						<tbody>
						<tr>
							<td>技师：{$info.tusername}</td>
							<td>技师头像：<img class="image-show" src="{$info.work_img}" width="80" height="80"></td>
						</tr>
						</tbody>
					</table>


					<table class="layui-table">
						<colgroup>
							<col width="150">
							<col width="150">
						</colgroup>
						<thead>
						<tr>
							<th colspan="4" >服务信息</th>
						</tr>
						</thead>
						<tbody>
						<tr>
							<td colspan="4">状态：
								{switch $info.status}
								    {case 0}待支付{/case}
									{case 1}已支付，待接单{/case}
									{case 2}已接单，待出发{/case}
									{case 3}已出发，待到达{/case}
									{case 4}已到达，待开始服务{/case}
									{case 5}已开始服务，待完成{/case}
									{case 6}已完成{/case}
									{case 7}已取消{/case}
									{case 8}已关闭{/case}
								{/switch}
							</td>
						</tr>

						{volist name="status_history" id="vo"}
							<tr>
								<td>{$vo.msg}</td>

								<?php
								    $extension_array = [];
                                    if(!empty($vo['extension_data'])) {
                                        $extension_array = json_decode($vo['extension_data'],true);
                                    }
								?>
								<td>
									{if condition="isset($extension_array['images'])"}  <img class="image-show" src="{$extension_array.images}" width="80" height="80"> {/if}
								</td>
								<td>
									{if condition="isset($extension_array['address']['address'])"} {$extension_array.address.address} {/if}
								</td>
								<td>{$vo.add_time|date="Y-m-d H:i:s",###}</td>
							</tr>
						{/volist}

						</tbody>
					</table>

				</div>
			</div>


		</form>
		<script src="__ADMIN_PATH__/component/layui/layui.js"></script>
		<script src="__ADMIN_PATH__/component/pear/pear.js"></script>
		<script>
			layui.use(['form', 'jquery', 'popup', 'loading'], function() {
				let form = layui.form;
				let $ = layui.jquery;
				var popup = layui.popup;
				let loading = layui.loading;

				/**
				 * 表单提交
				 */
				form.on('submit(service)', function(data) {
					$.ajax({
						url:"{:url('Service/save')}",
						type:"POST",
						dataType:"JSON",
						data:data.field,
						beforeSend: function () {
							loading.Load(1, "");
		                },
		                complete: function () {
		                	loading.loadRemove();
		                },
		                success:function(res)
		                {
		                	if(res.code == 0)
		                	{
		                		//正常业务
		                		popup.success(res.msg, function(){
		                			var index = parent.layer.getFrameIndex(window.name);
		                			parent.location.reload();
		                			parent.layer.close(index); //再执行关闭
	                        	});
		                	}else
		                	{
		                		//业务异常
		                		popup.warning(res.msg);
		                	}
		                },
		                error:function()
		                {
		                	loading.loadRemove();
		                	popup.failure('服务器错误');
		                }
		            });
		            return false;
		        });
				//图片放大
				$(document).on('click', '.image-show', function () {
					var url = $(this).attr('src');
					//获取当前窗口的宽度
					var scr_width = $(window).width();
					if (scr_width > 1200) {
						xp=600;   //大屏幕
					} else if (scr_width > 860) {
						xp=500;   //中屏幕
					} else {
						xp=300;   //超小屏幕
					}

					console.log(url);
					function getImageWidth(url, callback) {
						var img = new Image();
						img.src = url;
						if (img.complete) {
							callback(img.width, img.height)
						} else {
							img.onload = function () {
								callback(img.width, img.height)
							}
						}
					}
					getImageWidth(url, function (width, height) {
						if (height > xp) {
							var ratio = width / height;
							height = xp;
							width = height * ratio
						}
						if (width > xp) {
							var ratio = height / width;
							width = xp;
							height = width * ratio
						}
						layer.closeAll();
						layer.open({
							type: 1,
							closeBtn: 1,
							shade: false,
							title: false,
							shadeClose: false,
							area: ["auth", "auth"],
							content: '<img src="' + url + '" width="' + width + 'px" height="' + height + 'px">'
						})
					})
				});
		    });
		</script>
		<style type="text/css">
			.plug-file-upload-view li
			{
				display: inline;
			}
		</style>
		{include file="publics/ueditor" /}
		<!--编辑器事件必须放到ueditor下面-->
		<script type="text/javascript">
			var editor = UE.getEditor('editor-tag-introduce',{
		    	initialFrameWidth:'100%',
		    	initialFrameHeight:350,
		    	autoFloatEnabled:false,
		    	autoHeightEnabled:false,
		    	serverUrl:"{:url('ueditor/index',['path_type' => !empty($editor_path_type) ? $editor_path_type : 'common'])}"
		    });
		    var editor2 = UE.getEditor('editor-tag-taboos',{
		    	initialFrameWidth:'100%',
		    	initialFrameHeight:350,
		    	autoFloatEnabled:false,
		    	autoHeightEnabled:false,
		    	serverUrl:"{:url('ueditor/index',['path_type' => !empty($editor_path_type) ? $editor_path_type : 'common'])}"
		    });
		    var editor3 = UE.getEditor('editor-tag-notice',{
		    	initialFrameWidth:'100%',
		    	initialFrameHeight:350,
		    	autoFloatEnabled:false,
		    	autoHeightEnabled:false,
		    	serverUrl:"{:url('ueditor/index',['path_type' => !empty($editor_path_type) ? $editor_path_type : 'common'])}"
		    });
		</script>
	</body>
</html>